package com.sr365.changan.infrastructure.service;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.sr365.changan.infrastructure.domain.Domain;

/**
 * Created by WangXingchao.
 * User: WangXingchao (wangxingchao@gmail.com)
 * Date: 2010-6-21
 * Time: 12:05:14
 * Description:
 */
public interface BaseDomainService<T extends Domain> extends Service {
    /**
     * Load a object by id.
     * @param id
     * @return
     */
    T load(Long id);

    /**
     * Load a object by a regular property and its value.
     * @param propertyName
     * @param propertyValue
     * @return
     */
    T load(String propertyName, Object propertyValue);

    /**
     * Load a object by a set properties and their appropriate values.
     * @param propertyNames
     * @param propertyValues
     * @return
     */
    T load(String[] propertyNames, Object[] propertyValues);

    /**
     * Query all objects.
     * @param orderProperties
     * @return
     */
    List<T> findAll(String... orderProperties);

    /**
     * Query objects by a property and its value.
     * @param propertyName
     * @param propertyValue
     * @return
     */
    List<T> find(String propertyName, Object propertyValue);

    /**
     * Query objects by a set properties and their appropriate values.
     * @param propertyNames
     * @param propertyValues
     * @return
     */
    List<T> find(String[] propertyNames, Object[] propertyValues);

    /**
     * Save or Update a object.
     * @param o
     */
    @Transactional(readOnly = false)
    void save(T o);
}
